<?php

/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Exception
 *
 * @see http://www.last.fm/api/errorcodes
 * @author techi
 */
class LastFM_Exception extends Exception
{
    
    const INVALID_SERVICE = 2;
    
    const INVALID_METHOD = 3;
    
    const AUTHENTICATION_FAILED = 4;
    
    const INVALID_FORMAT = 5;
    
    const INVALID_PARAMS = 6;
    
    const INVALID_RESROUCE = 7;
    
    const INVALID_SESSION_KEY = 9;
    
    const INVALID_API_KEY = 10;
    
    const SERVICE_OFFLINE = 11;
    
    const INVALID_METHOD_SIGNATURE = 13;
    
    const SUSPENDED_API_KEY = 26;

    /**
     * Retrieve detail information about error code
     *
     * @return string
     */

    public function getCodeInfo()
    {
        switch ($this->code)
        {
            case self::INVALID_SERVICE:
                return "Invalid service: This service does not exist";

            case self::INVALID_METHOD:
                return "Invalid Method: No method with that name in this package";

            case self::AUTHENTICATION_FAILED:
                return "Authentication failed: You do not have permissions to access the service";

            case self::INVALID_FORMAT:
                return "Invalid format - This service doesn't exist in that format";

            case self::INVALID_PARAMS:
                return "Invalid parameters - Your request is missing a required parameter";

            case self::INVALID_SESSION_KEY:
                return "Invalid session key - Please re-authenticate";

            case self::INVALID_RESROUCE:
                return "Invalid Resource specified";

            case self::INVALID_API_KEY:
                return "Invalid API key - You must be granted a valid key by last.fm";

            case self::SERVICE_OFFLINE:
                return "Service Offline - This service is temporarily offline. Try again later.";

            case self::INVALID_METHOD_SIGNATURE:
                return "Invalid method signature supplied";

            case self::SUSPENDED_API_KEY:
                return "Suspended API key - Access for your account has been suspended, please contact Last.fm";

            default:
                return "Unknown Error Code";
        }
    }
}
